package cn.bdqn.web;

import cn.bdqn.entity.District;
import cn.bdqn.service.DistrictService;
import cn.bdqn.service.impl.DistrictServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


@WebServlet(value = "/air/toAdd")
public class AirToAddServlet extends HttpServlet {
    /*
    2. 跳转到添加空气质量信息页面.
    路径.
        GET		http://localhost/air/toAdd
    参数.
        无.
    响应.
        1. 全部区域数据,放到request域中.
        2. 转发到/WEB-INF/air_add.jsp
     */

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1. 创建区域表Service层对象
        DistrictService districtService = new DistrictServiceImpl();
        //2. 查询全部区域数据.
        List<District> list = districtService.findAll();
        //3. 放到request域中.
        req.setAttribute("list",list);
        //4. 转发到/WEB-INF/air_add.jsp
        req.getRequestDispatcher("/WEB-INF/air_add.jsp").forward(req,resp);
    }
}
